package cn.zqh.brand.controller;


import cn.zqh.bean.api.CommonResult;
import cn.zqh.brand.service.ShopCarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zqh
 * @since 2023-02-28
 */
@RestController
@RequestMapping("/car")
@Api("CarController")
public class ShopCarController {

    @Autowired
    private ShopCarService shopCarService;

    /**
      * @Author: zqh
      * @Date:
      * @Description: 把商品加入购物车
    */
    @ApiOperation(value = "把商品加入购物车")
    @PostMapping("/addCommodityToCar")
    public CommonResult addCommodityToCar(String commodityId,Integer number){
        return shopCarService.addCommodityToCar(commodityId,number);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 登录用户查询自己的购物车
    */
    @ApiOperation(value = "登录用户查询自己的购物车")
    @GetMapping("/getOwnShopCar")
    public CommonResult getOwnShopCar(Integer page,Integer size){
        return shopCarService.getOwnShopCar(page,size);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 把商品移除购物车
    */
    @ApiOperation(value = "把商品移除购物车")
    @DeleteMapping("removeItemsFromcCar")
    public CommonResult removeItemsFromcCar(String shopCarId){
        return shopCarService.removeItemsFromcCar(shopCarId);
    }

    /**
      * @Author: zqh
      * @Date:
      * @Description: 修改购物车中商品的信息
    */
    @ApiOperation(value = "修改购物车中商品的信息(修改商品的数量)")
    @PostMapping("updateCarCommodityInfo")
    public CommonResult updateCarCommodityInfo(String shopCarId,Integer number){
        return shopCarService.updateCarCommodityInfo(shopCarId,number);
    }
    
    /**
      * @Author: zqh
      * @Date: 
      * @Description: 管理员查询所有购物车信息
    */
    @ApiOperation(value = "管理员获取所有购物车信息")
    @GetMapping("adminGetALlShopCar")
    public CommonResult adminGetALlShopCar(Integer page,Integer size){
        return shopCarService.adminGetALlShopCar(page,size);
    }

}

